home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 414_02 / portable / mvscanw.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-17  |  2.4 KB  |  86 lines

  1. #include <stdarg.h>
  2. #include <string.h>
  3. #define    CURSES_LIBRARY    1
  4. #include <curses.h>
  5. #undef    mvscanw
  6.  
  7. #ifdef PDCDEBUG
  8. char *rcsid_mvscanw = "$Header: C:\CURSES\portable\RCS\mvscanw.c 2.1 1993/06/18 20:20:22 MH Rel MH $";
  9. #endif
  10.  
  11.  
  12.  
  13. /*man-start*********************************************************************
  14.  
  15.   mvscanw()    - read formatted from window
  16.  
  17.   X/Open Description:
  18.      These routines correspond to scanf.  The function scanw reads
  19.      input from the default window.  The function wscanw reads
  20.      input from the specified window.  The function mvscanw moves
  21.      the cursor to the specified position and then reads input from
  22.      the default window.  The function mvwscanw moves the cursor to
  23.      the specified position and then reads input from the specified
  24.      window.
  25.  
  26.      For all the functions, the routine wgetstr is called to get a
  27.      string from the window, and the resulting line is used as
  28.      input for the scan.  All character interpretation is carried
  29.      out according to the scanf function rules.
  30.  
  31.   PDCurses Description:
  32.      The old Bjorn Larssen code for the 68K platform has been removed
  33.      from this module.
  34.  
  35.   X/Open Return Value:
  36.      Upon successful completion, the scanw, mvscanw, mvwscanw and
  37.      wscanw functions return the number of items successfully
  38.      matched.  On end-of-file, they return EOF.  Otherwise they
  39.      return ERR.
  40.  
  41.   PDCurses Errors:
  42.      No errors.
  43.  
  44.   Portability:
  45.      PDCurses    int mvscanw( int y, int x, char *fmt, ...);
  46.      X/Open Dec '88    int mvscanw( int y, int x, char *fmt, ...);
  47.      BSD Curses    int mvscanw( int y, int x, char *fmt, ...);
  48.      SYS V Curses    int mvscanw( int y, int x, char *fmt, ...);
  49.  
  50. **man-end**********************************************************************/
  51.  
  52. int    mvscanw(int y, int x, char *fmt, ... )
  53. {
  54.     va_list args;
  55.     int    retval = ERR;
  56.  
  57. #ifdef PDCDEBUG
  58.     if (trace_on) PDC_debug("mvscanw() - called\n");
  59. #endif
  60.  
  61. #if    !defined (HC)
  62.     if (stdscr == (WINDOW *)NULL)
  63.         return( retval );
  64.  
  65.     if (wmove(stdscr, y, x) == ERR)
  66.         return( retval );
  67.  
  68.     wrefresh(stdscr);            /* set cursor position */
  69.  
  70.     /*
  71.      * get string
  72.      */
  73.     c_printscanbuf[0] = '\0';  /* reset to empty string */
  74.     if (wgetstr(stdscr, c_printscanbuf) == ERR)
  75.         return( retval );
  76.     va_start(args, fmt);
  77. #ifdef NO_VSSCANF
  78.     retval = PDC_vsscanf(c_printscanbuf, fmt, args);
  79. #else
  80.     retval = vsscanf(c_printscanbuf, fmt, args);
  81. #endif
  82.     va_end(args);
  83. #endif
  84.     return( retval );
  85. }
  86.